package com.yellow.cloud.security.oauth2.service;

import com.yellowframework.cloud.utils.Oauth2Utils;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.security.core.CredentialsContainer;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Set;

@Data
@EqualsAndHashCode(callSuper = true)
public class User extends Oauth2Utils.UserJwt implements UserDetails, CredentialsContainer {

    private final Set<GrantedAuthority> authorities;

    public User(String username, String password, Set<GrantedAuthority> authorities) {
        this.setUsername(username);
        this.setPassword(password);
        this.authorities = authorities;
    }

    @Override
    public void eraseCredentials() {
        this.setPassword(null);
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
